********************************************************     Table 3: Aggregate Treatment effects          ********************************************************clearuse Contracts_data_JOLE.dta
xtset sessfirm period


xtreg efficiency T_barrier T_barrier_bonus T_bonus , re cluster(session)xtreg profitfirm T_barrier T_barrier_bonus T_bonus , re cluster(session)xtreg profitworker T_barrier T_barrier_bonus T_bonus , re cluster(session)
*eststo: xtreg totalpay T_barrier T_barrier_bonus T_bonus , re cluster(session)
xtreg length_p T_barrier T_barrier_bonus T_bonus , re cluster(session)

xtreg efficiency T_barrier_bonus T_baseline T_bonus , re cluster(session)xtreg profitfirm  T_barrier_bonus T_baseline T_bonus , re cluster(session)xtreg profitworker  T_barrier_bonus T_baseline T_bonus , re cluster(session)
*eststo: xtreg totalpay T_barrier T_barrier_bonus T_bonus , re cluster(session)
xtreg length_p  T_barrier_bonus T_baseline T_bonus , re cluster(session)

xtreg efficiency T_barrier T_baseline T_bonus , re cluster(session)xtreg profitfirm T_barrier T_baseline T_bonus , re cluster(session)xtreg profitworker T_barrier T_baseline T_bonus , re cluster(session)
*eststo: xtreg totalpay T_barrier T_barrier_bonus T_bonus , re cluster(session)
xtreg length_p T_barrier T_baseline T_bonus , re cluster(session)

********************************************************     Figure 1: Compensation Profiles                 ********************************************************

clearuse Contracts_data_JOLE.dtadrop if length<2sort treatment relatperiod_ppreservecollapse (mean) totaloffer  effort wage totalpay if relatperiod_p>0,by(treatment relatperiod_p)
twoway (connected wage relatperiod_p if treatment==2, msymbol(circle) mcolor(black) msize(medlarge) clcolor(black) clpat(solid) clwidth(thick)) (connected totalpay relatperiod_p if treatment==1, msymbol(square) mcolor(gs4) msize(medlarge) clcolor(gs4) clpat(dash) clwidth(thick)) (connected wage relatperiod_p if treatment==4, msymbol(diamond) mcolor(gs11) msize(medlarge) clcolor(gs11) clwidth(thick)) (connected totalpay relatperiod_p if treatment==0, msymbol(triangle_hollow) mcolor(gs11) msize(medlarge) clcolor(gs11) clpat(dash_dot) clwidth(thick))  if relatperiod_p>0 & relatperiod_p<18, ytitle(Average compensation) yscale(range(30 60)) ylabel(30(10)60)  title("All long-term relationships",size(medsmall) color(black)) legend(order(1 "Wage, T-Barrier" 2 "Total Pay, T-Barrier-Bonus" 3 "Wage, T-Baseline" 4 "Total Pay, T-Bonus")) graphregion(color(white))
graph save alllong.gph, replace
restore

preserve
keep if length>=13
collapse (mean) totaloffer  effort wage totalpay if relatperiod_p>0,by(treatment relatperiod_p)
twoway (connected wage relatperiod_p if treatment==2, msymbol(circle) mcolor(black) msize(medlarge) clcolor(black) clpat(solid) clwidth(thick)) (connected totalpay relatperiod_p if treatment==1, msymbol(square) mcolor(gs4) msize(medlarge) clcolor(gs4) clpat(dash) clwidth(thick)) (connected wage relatperiod_p if treatment==4, msymbol(diamond) mcolor(gs11) msize(medlarge) clcolor(gs11) clwidth(thick)) (connected totalpay relatperiod_p if treatment==0, msymbol(triangle_hollow) mcolor(gs11) msize(medlarge) clcolor(gs11) clpat(dash_dot) clwidth(thick))  if relatperiod_p>0 & relatperiod_p<18, ytitle(Average compensation) yscale(range(30 60)) ylabel(30(10)60)  title("Long-term relationships lasting > 12",size(medsmall) color(black)) legend(order(1 "Wage, T-Barrier" 2 "Total Pay, T-Barrier-Bonus" 3 "Wage, T-Baseline" 4 "Total Pay, T-Bonus")) graphregion(color(white))
graph save reallong.gph, replace
restore

graph combine alllong.gph reallong.gph, graphregion(color(white)) xsize(13) ysize(7)


********************************************************     Regression Analysis of Compensation Profiles    ********************************************************

clearuse Contracts_data_JOLE.dtagen T_barrier_int=T_barrier*relatperiod_pgen T_barrier_bonus_int=T_barrier_bonus*relatperiod_p
gen T_bonus_int=T_bonus*relatperiod_p
gen T_baseline_int=T_baseline*relatperiod_p
xtset sessfirm period

gen finalperiod=period==18

xtreg totalpay T_barrier T_barrier_bonus T_bonus relatperiod_p T_barrier_int T_barrier_bonus_int T_bonus_int finalperiod if relatperiod_p>1 , re cluster(session)xtreg totalpay T_barrier T_barrier_bonus T_bonus relatperiod_p T_barrier_int T_barrier_bonus_int T_bonus_int finalperiod desiredeffort preveffort   if relatperiod_p>1 , re cluster(session)
xtreg totalpay T_barrier T_barrier_bonus T_bonus relatperiod_p T_barrier_int T_barrier_bonus_int T_bonus_int finalperiod if relatperiod_p>1 & length_p>12 , re cluster(session)xtreg totalpay T_barrier T_barrier_bonus T_bonus relatperiod_p T_barrier_int T_barrier_bonus_int T_bonus_int finalperiod desiredeffort preveffort  if relatperiod_p>1 & length_p>12, re cluster(session)


****************************************************************************************     Regression Analysis of conditioning of wage increases on effort in T_barrier    ****************************************************************************************
clearuse Contracts_data_JOLE.dta*Indicator for shirked in previous period (conditional on private offer)gen prevprivperform=prevpriveffort-prevprivdesired

*Indicator for raised wage relative to previous period, conditional on private offergen raisewage=wage>prevprivwage if relatperiod_p>1label var prevprivperform "Previous effort - previous desired effort"label var prevprivdesired "Previous desired effort"label var prevprivwage "Previous wage"label var relatperiod_p "Period of long-term relationship"dprobit raisewage prevprivperform prevprivdesired prevprivwage if T_barrier==1 & length_p>1 & relatperiod_p>1, cluster(session)


***************************************************************************************************** Effort levels in Long-Term vs. One-Shot Interactions  (figure not reported in published version) *****************************************************************************************************clearuse  Contracts_data_JOLE.dtasort treatment period
preservecollapse (mean) effort if relatperiod_p>1, by(treatment period)
twoway  (connected effort period if treatment==2 , msymbol(circle) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(thick)) (connected effort period if treatment==1 , msymbol(square) mcolor(gs4) msize(medlarge) clcolor(gs4) clpat(dash) clwidth(thick)) (connected effort period if treatment==4 , msymbol(diamond) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(solid) clwidth(thick)) (connected effort period if treatment==0 , msymbol(triangle_hollow) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(dash_dot) clwidth(thick)) , title("Long-term relationships",size(medsmall) color(black)) ytitle("Average effort in long-term relationships") ylabel(1(1)10) xtitle(Market period) xlabel(1(1)18) legend(order(1 "T-Barrier" 2 "T-Barrier-Bonus" 3 "T-Baseline" 4 "T-Bonus"))  graphregion(color(white))*twoway (connected effort period if treatment==4 , msymbol(circle) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(medthick)) (connected effort period if treatment==2 , msymbol(circle_hollow) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(medthick)) (connected effort period if treatment==1 , msymbol(diamond) mcolor(gs11) msize(medlarge) clcolor(gs11) clpat(solid) clwidth(medthin)) (connected effort period if treatment==0 , msymbol(diamond_hollow) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(solid) clwidth(medthin)) , ytitle("Average effort in long-term relationships") ylabel(1(1)10) xtitle(Market period) xlabel(1(1)18) legend(order(1 "T-Baseline" 2 "T-Barrier" 3 "T-Barrier-Bonus" 4 "T-Bonus"))  scheme(sj)graph save e_long.gph,replace
restore

preserve
collapse (mean) effort if relatperiod_p<2, by(treatment period)

twoway  (connected effort period if treatment==2 , msymbol(circle) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(thick)) (connected effort period if treatment==1 , msymbol(square) mcolor(gs4) msize(medlarge) clcolor(gs4) clpat(dash) clwidth(thick)) (connected effort period if treatment==4 , msymbol(diamond) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(solid) clwidth(thick)) (connected effort period if treatment==0 , msymbol(triangle_hollow) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(dash_dot) clwidth(thick)) , title("Initial/one-shot interactions",size(medsmall) color(black)) ytitle("Average effort in initial/one-shot interactions") ylabel(1(1)10) xtitle(Market period) xlabel(1(1)18) legend(order(1 "T-Barrier" 2 "T-Barrier-Bonus" 3 "T-Baseline" 4 "T-Bonus"))  graphregion(color(white))*twoway (connected effort period if treatment==4 , msymbol(circle) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(medthick)) (connected effort period if treatment==2 , msymbol(circle_hollow) msize(medlarge) mcolor(black) clcolor(black) clpat(solid) clwidth(medthick)) (connected effort period if treatment==1 , msymbol(diamond) mcolor(gs11) msize(medlarge) clcolor(gs11) clpat(solid) clwidth(medthin)) (connected effort period if treatment==0 , msymbol(diamond_hollow) msize(medlarge) mcolor(gs11) clcolor(gs11) clpat(solid) clwidth(medthin)) , ytitle("Average effort in long-term relationships") ylabel(1(1)10) xtitle(Market period) xlabel(1(1)18) legend(order(1 "T-Baseline" 2 "T-Barrier" 3 "T-Barrier-Bonus" 4 "T-Bonus"))  scheme(sj)graph save e_one.gph, replace
restore

graph combine e_long.gph e_one.gph , graphregion(color(white)) xsize(10) ysize(6)


****************************************************************************************     Regression Analysis of Effort Drop: From First to Second Relationship Period    ****************************************************************************************

clearuse  Contracts_data_JOLE.dtagen idiff=effort-preveffortgen edrop= idiff<0gen periodsq=period*periodxtset sessfirm period

xtreg edrop T_barrier T_barrier_bonus T_bonus if relatperiod_p==2, re cluster(session)
xtreg edrop T_barrier T_barrier_bonus T_bonus wage desiredeffort prevwage prevdesired preveffort if relatperiod_p==2, re cluster(session)
xtreg edrop T_barrier T_barrier_bonus T_bonus wage desiredeffort prevwage prevdesired preveffort period periodsq  if relatperiod_p==2, re cluster(session)



********************************************************     Figure 2: Bonus-Effort Relation                 ********************************************************

clearuse Contracts_data_JOLE.dtaegen bonus_b=mean(actualbonus) if T_bonus==1,by(effort)egen bonus_bEPL=mean(actualbonus) if T_barrier_bonus==1,by(effort)egen maxbonusb=max(bonus_b),by(effort)egen maxbonusbEPL=max(bonus_bEPL),by(effort)
egen obonus_b=mean(offeredbonus) if T_bonus==1,by(effort)egen obonus_bEPL=mean(offeredbonus) if T_barrier_bonus==1,by(effort)egen omaxbonusb=max(obonus_b),by(effort)egen omaxbonusbEPL=max(obonus_bEPL),by(effort)sort treatment effort graph bar (mean) maxbonusbEPL (mean) maxbonusb if  (treatment==2 | treatment==0) , over(effort) bar(1, bfcolor(white) blcolor(black) blwidth(medium)) bar(2, bfcolor(black) blcolor(black) blwidth(medium)) ytitle(Actual bonus as a function of effort) legend(order(1 "T-Barrier-Bonus" 2 "T-Bonus")) graphregion(color(white))

*********************************************************     Regression Analysis for Offered and Actual Bonus *********************************************************

clearuse Contracts_data_JOLE.dtagen finalperiod=period==18
xtset sessfirm period
xtreg offeredbonus T_barrier_bonus  wage desiredeffort finalperiod if (T_bonus==1 | T_barrier_bonus==1), re cluster(session)
xtreg offeredbonus T_barrier_bonus  wage desiredeffort finalperiod if relatperiod_p>1 & (T_bonus==1 | T_barrier_bonus==1), re cluster(session)
xtreg offeredbonus T_barrier_bonus  wage desiredeffort finalperiod if relatperiod_p<2 & (T_bonus==1 | T_barrier_bonus==1), re cluster(session)

xtreg actualbonus T_barrier_bonus  effort offeredbonus wage desiredeffort finalperiod if (T_bonus==1 | T_barrier_bonus==1), re cluster(session)
xtreg actualbonus T_barrier_bonus  effort offeredbonus wage desiredeffort finalperiod if relatperiod_p>1 & (T_bonus==1 | T_barrier_bonus==1), re cluster(session)
xtreg actualbonus T_barrier_bonus  effort offeredbonus wage desiredeffort finalperiod if relatperiod_p<2 & (T_bonus==1 | T_barrier_bonus==1), re cluster(session)


********************************************************     Figure 3: Firing Threat                         ********************************************************

clearuse Offers_data_JOLEsort sessfirm periodgen no_rehire=0by sessfirm: replace no_rehire =1 if prenewoffer==0 sort treatment preveffortegen T_wage_norehire=mean(no_rehire) if treatment==4, by(preveffort)egen T_bonus_norehire=mean(no_rehire) if treatment==0, by(preveffort)
twoway (connected T_wage_norehire preveffort if treatment==4 , msymbol(diamond) mcolor(black) clcolor(black) clwidth(medthick) clpat(solid)) (connected T_bonus_norehire preveffort if treatment==0 , msymbol(triangle_hollow) mcolor(gs11) clcolor(gs11) clwidth(medthick) clpat(dash)), ytitle(Probability that firm terminates the relationship) xtitle("Previous period effort") xlabel(1(1)10) legend(order(1 "T-Baseline" 2 "T-Bonus")) graphregion(color(white))


*******************************************************************     Weaker Conditioning of Re-hiring on performance in T_Bonus *******************************************************************
clearuse Offers_data_JOLEsort sessfirm periodgen no_rehire=0by sessfirm: replace no_rehire =1 if prenewoffer==0 sort treatment preveffortegen T_wage_norehire=mean(no_rehire) if treatment==4, by(preveffort)egen T_bonus_norehire=mean(no_rehire) if treatment==0, by(preveffort)gen T_baseline=treatment==4gen T_bonus=treatment==0gen T_bonus_effort=T_bonus*effort
dprobit no_rehire T_bonus T_bonus_effort effort if T_bonus==1 | T_baseline==1, cluster(session)




****************************************************************************     Starting Wage and Effort Levels/Relationship Length in T_baseline   ****************************************************************************clearuse Contracts_data_JOLE.dtaegen aveeffort=mean(effort) if relatperiod_p>1,by(sessfirm relat)gen swage=wagereplace swage=0 if relatperiod_p~=2egen startwage=max(swage),by(sessfirm relat)collapse (max) length_p aveeffort startwage ,by(treatment session sessfirm relat)

xtset sessfirm relat

xtreg aveeffort startwage if treatment==4, cluster(session) re

xtreg length_p startwage if treatment==4, cluster(session) re


***********************************************     Wage cuts and worker performance       ***********************************************

clearuse Contracts_data_JOLE.dta

by sessfirm: gen prevofferedbonus=offeredbonus[_n-1] if period>1

gen shirk=effort<desiredeffort

by sessfirm: gen prevprivate=private[_n-1]==1 if period>1

by sessfirm: gen fired=sessworker[_n]~=sessworker[_n-1] if period<18 & prevprivate==1 & private==1

gen edrop=effort<preveffort

gen wagedrop=wage<prevwage

gen odiff=prevtotaloffer-totaloffer
gen odrop=odiff>0

xtset sessfirm period

*In all regressions, condition on not being fired in current period
dprobit shirk wagedrop wage desiredeffort prevdesired if T_baseline==1 &  fired==0 ,  cluster(session)

*Results are robust to dropping final period
dprobit shirk wagedrop wage desiredeffort prevdesired if T_baseline==1 &  fired==0 & period<18,  cluster(session)

*Wage cuts are positively related to shirking probability in T_bonus, but not significant and smaller, which makes sense given that 
*workers are worried about getting the bonus if they shirk.
dprobit shirk wagedrop wage offeredbonus prevofferedbonus desiredeffort prevdesired if T_bonus==1 &  fired==0 ,  cluster(session)
dprobit shirk wagedrop wage offeredbonus prevofferedbonus desiredeffort prevdesired if T_bonus==1 &  fired==0 & period<18,  cluster(session)




